﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
using System.Windows.Threading;
using System.Text;

namespace Cjc.ThreeDeemium
{
	/// <summary>
	/// Interaction logic for App.xaml
	/// </summary>
	public partial class App : Application
	{
		void App_DispatcherUnhandledException( object sender, DispatcherUnhandledExceptionEventArgs e )
		{
			var stringBuilder = new StringBuilder();
			stringBuilder.AppendFormat( "{0}\n", e.Exception.Message );
			stringBuilder.AppendFormat( "Exception handled on main UI thread {0}.", e.Dispatcher.Thread.ManagedThreadId );

			var result = MessageBox.Show(
				"Application must exit:\n\n" + stringBuilder.ToString() + "\n\nSave before exit?",
				"app",
				MessageBoxButton.YesNo,
				MessageBoxImage.Error );

//			if ( result == MessageBoxResult.Yes )

			this.Shutdown( -1 );

			e.Handled = true;
		}
	}
}
